﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Security.Cryptography;


class Sha1
{
    private const int BUFFER_SIZE = 8 * 1024;

    static void Main(string[] args)
    {
        SHA1 sha = new SHA1CryptoServiceProvider();
        string inputFile = @"C:\Windows\explorer.exe";
        byte[] result = sha.ComputeHash(GetBytesFromFile(inputFile));
        foreach(byte symbol in result)
        {
            Console.Write("{0:X}",symbol);
        }
        Console.WriteLine();
    }

    static byte[] GetBytesFromFile(string fileName)
    {
        FileStream inFile = new FileStream(fileName, FileMode.Open, FileAccess.Read);

        using (inFile)
        {
            byte[] fileContents = new byte[inFile.Length];
            int offset = 0;
            while (true)
            {
                int bytesRead = inFile.Read(fileContents, offset, fileContents.Length-offset);
                if (bytesRead == 0)
                {
                    break;
                }
                offset += bytesRead;
            }
            return fileContents;
        }
    }
}
